|
|
|
|
|
|
|
As with the undo/Memento operations, the client form invokes this method on the FormController class instance. However, because the operations for saving information involve file operations and database operations, further details on implementation are addressed on Day 17, The File Operations Subsystem, and Day 19, The Database Access Subsystem. |
|
|
|
|
|
|
|
|
Arguments and Preconditions |
|
|
|
|
|
|
|
|
Some arguments listed earlier require special attention. In Listing 11.3, the method clickedAddBtn has the following arguments: |
|
|
|
|
|
|
|
|
ByRef argObject
argString As String |
|
|
|
|
|
|
|
|
Because the type of argObject is not known, the method had to test it. That is, the precondition for this method is that the object referenced by argObject has to be either a TextBox, Label, ListBox, or ComboBox. A type failure of any of these preconditions means that the method can't process the event/stimulus. The argString argument in this example didn't have an associated precondition. The clickedModifyBtn and clickedDeleteBtn methods follow the same general pattern. |
|
|
|
|
|
|
|
|
In Listing 11.6, you came across several additional arguments. Look at the createMemento method. The object, theBusinessMemento, has a method, setState, that accepts an argument that represents an array of property values (arrMemento). No preconditions applied for this argument, although the method is not meaningful unless there are values in the Memento array. |
|
|
|
|
|
|
|
|
In the setMemento method, you find an argument, argMemento, that is of type BusinessMemento. Here, you've enlisted the help of the Visual Basic compiler in making sure the argument is, indeed, of the expected type. |
|
|
|
|
|
|
|
|
Returns and Postconditions |
|
|
|
|
|
|
|
|
For the most part, the returns and postconditions were straightforward. In Listing 11.4, you read the following line of code: |
|
|
|
|
|
|
|
|
Set theBusinessMemento = theBusiness.createMemento |
|
|
|
|
|
|
|
|
The createMemento method returns an object of type, BusinessMemento. This means that as a postcondition, theBusinessMemento had to be declared as the expected type. |
|
|
|
|
|
|
|
|
The other postcondition was that the state of theBusiness object would change, which necessitated the need to create a Memento to memorize the previous state. |
|
|
|
|
|